﻿$(document).ready(function () {
    var url = location.href;
    //alert(url)  http://localhost:4946/pages/Default.aspx
    var foo = url.split('/')[4];

    $("#main-nav li").each(function () {
        var a = $(this).find("a");
        var href = a.attr("href");
        if (href == foo) {
            a.parent().parent().prev().addClass("nav-top-item current");
            //a.parent().parent().slideToggle("slow");
            a.addClass("current");
            return;
        }
    });

    $("#main-nav li ul li a").click(function () {
        $("#main-nav li ul li").find("a").removeClass("current");
        $(this).addClass("current");
        $(this).parent().parent().prev().addClass("nav-top-item current");

    });
});

function logOff() {
    $.ajax({
        type: "Post",
        contentType: "application/json",
        url: "../webServices/LoginService.asmx/LogOff",
        data:{},
        success: function () {
            //alert('ok');
            window.location.href = "../Login.aspx";
        },
        error: function () {
            //alert('error');
            window.location.href = "../Login.aspx";
        }
    });
    return false;
}
